package com.company.huisuo.biz.fragment

import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.company.huisuo.R
import com.company.huisuo.base.BaseFragment
import com.company.huisuo.biz.activity.ArtistRewardActivity
import com.company.huisuo.biz.adapter.KRoomArtistListAdapter
import com.company.huisuo.biz.adapter.KRoomArtistListDanceAdapter
import com.company.huisuo.biz.bean.ArtistBean
import com.company.huisuo.biz.dialog.ArtistClothesDialog
import com.company.huisuo.databinding.FragmentKroomArtistListBinding
import com.lxj.xpopup.XPopup

/**
 * 艺人列表
 */
class KRoomArtistListFragment : BaseFragment<FragmentKroomArtistListBinding>() {

    private val mArtistAdapter by lazy {
        KRoomArtistListAdapter()
    }
    private val mDanceAdapter by lazy {
        KRoomArtistListDanceAdapter()
    }
    private val mArtistClothesDialog by lazy {
        XPopup.Builder(requireActivity()).asCustom(ArtistClothesDialog(requireActivity()))
    }

    companion object {
        fun newInstance(): KRoomArtistListFragment {
            return KRoomArtistListFragment()
        }
    }

    override fun initView() {
        mBinding?.rcvArtist?.apply {
            layoutManager = LinearLayoutManager(activity, RecyclerView.HORIZONTAL, false)
            adapter = mArtistAdapter
        }
        mBinding?.rcvDance?.apply {
            layoutManager = LinearLayoutManager(activity, RecyclerView.HORIZONTAL, false)
            adapter = mDanceAdapter
        }

        mArtistAdapter.addOnItemChildClickListener(R.id.tv_huanzhuang) { adapter, view, pos ->
            //艺人换装
            mArtistClothesDialog.show()
        }
        mArtistAdapter.addOnItemChildClickListener(R.id.tv_dashang) { adapter, view, pos ->
            //打赏艺人
            ArtistRewardActivity.start(requireActivity(), mArtistAdapter.getItem(pos))
        }

        mArtistAdapter.submitList(ArtistBean.LIST)
//        mDanceAdapter.submitList(mockDanceData())
    }

    override fun initData() {

    }
}